package com.example.shushiyunsst.fragment.main.home.recycler.provider

import android.content.Context
import android.util.Log
import android.view.View
import com.example.library_common.adapter.multi.JssMultiItemEntity
import com.example.library_common.adapter.multi.JssMultiItemViewHolder
import com.example.library_common.adapter.multi.JssNewMultipleAdapter
import com.example.shushiyunsst.R
import com.example.shushiyunsst.fragment.main.home.child.new_sale.recycler.bean.NewSaleEntity
import com.example.shushiyunsst.fragment.main.home.recycler.bean.HomeEntity
import com.example.shushiyunsst.fragment.main.home.recycler.bean.NotifyEntityWrapper
import com.example.shushiyunsst.widget.NewsFlipperView
import kotlin.math.log

class NotifyProvider(view: View) : JssMultiItemViewHolder<NotifyEntityWrapper>(view) {

    override fun getItemLayout() = R.layout.notify_provider_item

    private var mNewsFlipperView: NewsFlipperView? = null

    override fun convert(context: Context?, mItem: NotifyEntityWrapper?) {
        super.convert(context, mItem)

        mNewsFlipperView = itemView.findViewById(R.id.mNewsFlipperView)

        val mls = mutableListOf<String>()

        val list = mItem?.list ?: emptyList()
        Log.d("convert", "convert: $list")
        for (item in list) {
            mls.add(item.title)
//            Log.d("convert", "convert: ${item.title}")
        }
        mNewsFlipperView?.setData(mls)

        mNewsFlipperView?.setMreOverClickListener(object :
            NewsFlipperView.SubClassifyMoreOverClickListener {
            override fun clickListener() {
                if (adapter is JssNewMultipleAdapter<*>) {
                    val itemViewClick =
                        (adapter as JssNewMultipleAdapter<JssMultiItemEntity>)
                            .adapterViewItemViewClick
                    itemViewClick?.onAdapterViewListItemViewClick(
                        mItem as JssMultiItemEntity,
                        HomeEntity.Notify_TYPE
                    )
                }
            }

        })

    }

//    override fun onViewAttachedToWindow() {
//        super.onViewAttachedToWindow()
//        mNewsFlipperView = itemView.findViewById(R.id.mNewsFlipperView)
//        mNewsFlipperView?.start()
//    }
//
//    //
//    override fun onViewDetachedFromWindow() {
//        super.onViewDetachedFromWindow()
//        mNewsFlipperView = itemView.findViewById(R.id.mNewsFlipperView)
//        mNewsFlipperView?.stop()
//    }
}


